package
{
	import flash.display.Sprite;
	import flash.geom.Point;
	
	import com.atomos.log.AtomosDebug;
	import com.atomos.particle.DisplayObjectParticle;
	import com.atomos.strategy.action.StackAction;
	import com.atomos.strategy.action.display.AlphaLifeTweenAction;
	import com.atomos.strategy.action.display.DisplayObjectDeadAction;
	import com.atomos.strategy.action.display.DisplayObjectMoveAction;
	import com.atomos.strategy.action.display.ScaleLifeTweenAction;
	import com.atomos.strategy.action.life.LifeAction;
	import com.atomos.strategy.action.position.MoveAction;
	import com.atomos.strategy.emission.ByRateLimitedEmission;
	import com.atomos.strategy.initialize.StackInitializer;
	import com.atomos.strategy.initialize.display.DisplayObjectInitalizer;
	import com.atomos.strategy.initialize.life.LifeInitializer;
	import com.atomos.strategy.initialize.velocity.StreamInitializer;
	import com.atomos.system.SimpleParticleSystem;
	import com.atomos.utils.AtomosMonitorFieldsList;
	import com.bourre.log.Logger;
	import com.bourre.utils.FlashInspectorLayout;
	import com.kairos.engine.RTBeacon;
	import com.kairos.utils.Monitor;
	import com.kairos.utils.MonitorFieldsList;	
	
	[SWF(width="550",height="400",frameRate="40",backgroundColor="#000000")]
	public class DisplayObjectParticleExample extends Sprite
	{
		protected var _system : SimpleParticleSystem;
		
		public function DisplayObjectParticleExample ()
		{
			Logger.getInstance().addLogListener( FlashInspectorLayout.getInstance(), AtomosDebug.CHANNEL );
			
			// Set the maximum step for the current animation
			RTBeacon.getInstance().setMaxStepSize( 100 );
			
			// Creating a monitor 
			var monitor : Monitor = new Monitor( 140, 60 );
			monitor.addField( MonitorFieldsList.FPS );
			monitor.addField( MonitorFieldsList.MEMORY );
			monitor.addField( AtomosMonitorFieldsList.PARTICLES );
			monitor.start();
			addChild ( monitor );
			
			// Creating the stack for particles action
			var action : StackAction = new StackAction();
			action.add( new LifeAction() );
			action.add( new ScaleLifeTweenAction ( new Point ( 1, 1 ), new Point ( 4, 4 ) ) );
			action.add( new AlphaLifeTweenAction ( 1, 0 ) );
			action.add( new MoveAction() );
			action.add( new DisplayObjectMoveAction() );
			action.add( new DisplayObjectDeadAction() );
			
			// Creating the stack for particles initialization
			var initializer : StackInitializer = new StackInitializer();
			initializer.add ( new LifeInitializer ( 1500 ) );
			initializer.add ( new DisplayObjectInitalizer ( Circle, this, DisplayObjectInitalizer.BACK ) );
			initializer.add ( new StreamInitializer ( new Point( 0, -100 ), 30, 45 ) );
			
			// Creating an emission witch have started 300ms before call and run indefinitely
			var emission : ByRateLimitedEmission = new ByRateLimitedEmission ( DisplayObjectParticle, new Point( 300, 350 ), 20, Number.POSITIVE_INFINITY );
			
			// Creating the emitter with stacks and launch the emission
			_system = new SimpleParticleSystem( initializer, action );
			_system.emit( emission ); 
		}
	}
}

import flash.display.Shape;

internal class Circle extends Shape
{
	public function Circle ()
	{
		graphics.beginFill( 0xffffff );
		graphics.drawCircle( -10, -10, 10 );
		graphics.endFill();
	}
}